import request from '@/utils/request'

// api地址
const api = {
  todoCounts: '/v1/order/stat',
  list: '/v1/order/list',
  detail: '/v1/order/get',
  express: '/v1/order/getExpress',
  cancel: '/v1/order/cancel',
  receipt: '/v1/order/receipt',
  pay: '/v1/order/pay'
}

// 当前用户待处理的订单数量
export function todoCounts(param) {
  return request.get(api.todoCounts, param)
}

// 我的订单列表
export function list(param, option) {
  return request.get(api.list, param, option)
}

// 订单详情
export function detail(order_id, param) {
  return request.get(api.detail, { order_id, ...param })
}

// 获取物流信息
export function express(orderId, param) {
  return request.get(api.express, { orderId, ...param })
}

// 取消订单
export function cancel(order_id, data) {
  return request.post(api.cancel, { order_id, ...data })
}

// 确认收货
export function receipt(order_id, data) {
  return request.post(api.receipt, { order_id, ...data })
}

// 立即支付
export function pay(order_id, pay_type, param) {
  return request.post(api.pay, { order_id, pay_type, ...param })
}
